home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu168a.dms / pu168a.adf / Scripts / tutorial3.art < prev    next >
Text File  |  1991-10-20  |  4KB  |  152 lines

  1. !---------------------------------------------------------------
  2. !
  3. ! TUTORIAL3 - RayDance tutorial script #3.
  4. !
  5. ! This script demonstrates specular hilite control on a 4 x 5
  6. ! array of spheres.
  7. !
  8. ! Concepts include :
  9. !
  10. !  o Declaring PHONG surfaces with different ks and n values.
  11. !
  12. !  o Declaring and calling procedures
  13. !
  14. !  o Using variables
  15. !
  16. !  o Using WHILE loops
  17. !
  18. !  o Using a PRINT statement to display the contents of
  19. !    variables
  20. !
  21. !---------------------------------------------------------------
  22.  
  23. ! Provide some informative text on the message window describing
  24. ! this script.
  25.  
  26. ? "TUTORIAL3 - This script defines a scene with four rows of\n",
  27.   "5 spheres.  Each sphere will be the same color but will\n",
  28.   "have different specular reflection surface values (ks and\n",
  29.   "n).  ks will increase toward the bottom rows.  n will\n",
  30.   "increase toward the right side of the screen.  Higher\n",
  31.   "values of ks increase the brightness of specular\n",
  32.   "highlighting while higher values of n will make the\n",
  33.   "highlight more focused.\n";
  34.  
  35. ! The camera will be positioned along the negative y axis
  36. ! looking at the origin.
  37.  
  38. CAMERA'POS = [0,-3000,0];
  39. CAMERA'TARGET = [0,0,0];
  40.  
  41.  
  42. ! Define the color of the sphere
  43.  
  44. SPHERE_COLOR : COLOR ( RGB, [0.8,0.4,0] );  ! Lt orange
  45.  
  46.  
  47. ! Declare our variables.
  48.  
  49. real   XPOS,ZPOS;
  50.  
  51. real   KS,N;
  52.  
  53.  
  54. ! Declare a procedure (subroutine).  This procedure will create
  55. ! a sphere at the specified location with the specified surface
  56. ! characteristics.
  57. !
  58. ! NOTE: All variables declared inside a procedure (including
  59. ! surfaces) are local.  This means that each time you call the
  60. ! procedure a completely new and unique variable will be
  61. ! created.  We will exploit this feature to create a seperate
  62. ! surface for each sphere within this procedure.
  63.  
  64. proc MAKESPHERE( vector POS, real RADIUS,
  65.                  real PHONG_KS, real PHONG_N )
  66.  
  67. !                  ka  kd  ks       n      km  kr  ir  kb  flags
  68.   SPHERE_SURF :
  69.     SURFACE(PHONG, 1.0,1.0,PHONG_KS,PHONG_N,0.0,0.0,0.0,0.0,0 );
  70.  
  71. ! Create the actual sphere
  72.  
  73.   SPHERE( POS, RADIUS, SPHERE_COLOR, SPHERE_SURF );
  74.  
  75. ! Print the position and surface parameters of each sphere
  76.  
  77.   ? "Creating sphere,", POS, RADIUS,
  78.     "Ks & n", PHONG_KS, PHONG_N, "\n";
  79.  
  80. endproc
  81.  
  82.  
  83. ! Setup two loops to create the spheres.  The spheres will be
  84. ! placed in rows parallel to the x axis and columns parallel to
  85. ! the z axis.  
  86.  
  87. XPOS = -800;
  88. N = 1;
  89.  
  90. while (XPOS <= 800) {
  91.  
  92.   ZPOS = 600;
  93.   KS = 0.1;
  94.  
  95.   while (ZPOS >= -600) {
  96.  
  97. ! Call the procedure that will construct the sphere.  Since
  98. ! radius was declared as a REAL we MUST pass a real constant,
  99. ! 100.0.  Passing 100 (an integer constant) will cause syntax
  100. ! errors.
  101.  
  102.     MAKESPHERE( [XPOS,0,ZPOS], 100.0, KS, N );
  103.  
  104.     KS = KS + .2;
  105.     ZPOS = ZPOS - 400;
  106.   }
  107.  
  108.   XPOS = XPOS + 400;
  109.   N = N * 3;
  110. }
  111.  
  112.  
  113. ! Specify the ambient light.  This will provide illumination for
  114. ! the areas that are shadows from the star light source.
  115. ! Positioning of ambient lights is reserved for future
  116. ! expansion.  For now, set position to [0,0,0].  The intensity
  117. ! of ambient lights should range from [0,0,0] to [1,1,1].  We
  118. ! will use a muted white light. The ambient direction is UP, but
  119. ! since K1 and K2 are zero this light is non-directional making
  120. ! direction a place holder.  UP is toward the positive z-axis.
  121.  
  122. !        always 0's  color      direction k1(base) k2(range)
  123.  
  124. AMBIENT( [0,0,0], [0.6,0.6,0.6], [0,0,1],   0,     0 );
  125.  
  126.  
  127. ! Specify the STAR light.  Position it above, behind, and to the
  128. ! right of the camera.  Since the light of a star doesn't
  129. ! diminish with distance good light values range from [0,0,0] to
  130. ! [1,1,1].  Make a slightly yellowish star.
  131.  
  132. !       position          color   radius
  133.  
  134. STAR( [5000,-5000,4000], [1,1,.9], 300 );
  135.  
  136.  
  137. ! Set the background color to a dark, muddy red
  138.  
  139. !           type   rgb color value
  140.  
  141. BACKGROUND( PLAIN, [0.2,0.05,0.05] );
  142.  
  143.  
  144. ! The scene has now been constructed, render it!
  145.  
  146. RENDER;
  147.  
  148.  
  149. ! All scripts must terminate with an END
  150.  
  151. END
  152.